package com.company.ljh.easy;

import com.company.ljh.utils.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * 104.
 *    //二叉树前序遍历 先访问父节点，然后遍历左子树，最后遍历右子树
 *     //二叉树中序遍历 先遍历左子树，访问根节点，遍历右子树
 *     //二叉树后序遍历 先遍历左子树，再遍历右子树，最后访问根节点
 * @projectName:leet_code
 * @see:com.company.ljh.easy
 * @author:ljh
 * @createTime:2022/3/24 14:18
 * @version:1.0
 */
public class 二叉树最大深度 {
    private static int maxSize = 0;
    public int maxDepth(TreeNode root) {
        List<Integer> leafNodeList1 = new ArrayList();
        //递归
        int depth = 0;
        findDepth(root,depth);
        int max = maxSize ;
        maxSize = 0;
        return max;
    }
    private void findDepth(TreeNode node,int depth){
        if (node == null){
            return;
        }
        depth++;
        if (maxSize < depth){
            maxSize = depth;
        }
        findDepth(node.left,depth);
        findDepth(node.right,depth);
    }
}
